﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Data {
    public partial class ProfitMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Profit> {
        public ProfitMap() {
            // table
            ToTable("mc_Profit", "dbo");
            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.Amount)
                .HasColumnName("Amount")
                .HasPrecision(18, 6)
                .IsRequired();

            // Relationships
            HasRequired(t => t.Order)
                .WithMany(t => t.Profits)
                .HasForeignKey(d => d.OrderId)
                .WillCascadeOnDelete(false);
            HasRequired(t => t.Product)
                .WithMany()
                .HasForeignKey(d => d.ProductId)
                .WillCascadeOnDelete(false);
            HasRequired(t => t.Merchant)
                .WithMany()
                .HasForeignKey(t => t.MerchantId)
                .WillCascadeOnDelete(false);
        }
    }
}
